package com.hzx.ssm.controller;

import com.hzx.ssm.entity.Comment;
import com.hzx.ssm.entity.ResBean;
import com.hzx.ssm.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/comment")
@Controller
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("addComment")
    @ResponseBody
    @ApiOperation("用户对墙消息评论")
    public ResBean addComment(Comment comment){
        return commentService.addComment(comment);
    }

    @DeleteMapping("deleteMyComment")
    @ResponseBody
    @ApiOperation("用户删除自己的评论")
    public ResBean deleteMyComment(@RequestParam("comment_id") String comment_id,
                                   @RequestParam("user_id") String user_id){
        return commentService.deleteMyComment(comment_id, user_id);
    }

    @DeleteMapping("deleteCommentById")
    @ResponseBody
    @ApiOperation("管理员删除评论")
    public ResBean deleteCommentById(@RequestParam("comment_id") String comment_id){
        return commentService.deleteOneById(comment_id);
    }

    @GetMapping("findCommentToMessage")
    @ResponseBody
    @ApiOperation("查找此墙消息下的所有评论")
    public ResBean findCommentToMessage(@RequestParam("message_id") String message_id){
        return commentService.findCommentToMessage(message_id);
    }

}
